package com.quanxiaoha.weblog.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * 用户行为类型枚举
 */
@Getter
@AllArgsConstructor
public enum BehaviorTypeEnum {

    VIEW(1, "浏览", new BigDecimal("1.0")),
    LIKE(2, "点赞", new BigDecimal("3.0")),
    FAVORITE(3, "收藏", new BigDecimal("5.0")),
    SHARE(4, "分享", new BigDecimal("4.0"));

    private final Integer code;
    private final String description;
    private final BigDecimal defaultScore;

    /**
     * 根据code获取枚举
     * @param code 行为类型代码
     * @return 枚举值
     */
    public static BehaviorTypeEnum getByCode(Integer code) {
        for (BehaviorTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
}
